﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SSharp.Core.DataTypes;
using SSharp.Core.Evaluator;

namespace SSharp.Core.Builtins.Functions {
	public static class PrimitiveProcedures {
		public static readonly PrimitiveProcedure RenameProcedure = new PrimitiveProcedure("rename-lambda",
			args => {
				if (args.Length != 2) {
					throw new ApplicationError("rename-lambda expects two arguments, given " + args.Length);
				} else {
					Procedure proc = args[0] as Procedure;
					string name = args[1] as string;

					if (proc == null) {
						throw new ApplicationError("rename-lambda expects procedure as first argument, given " + args[0]);
					}

					if (name == null) {
						throw new ApplicationError("rename-lambda expects string as second argument, given " + args[1]);
					}

					return proc.Rename(name);
				}
			});
	}
}
